﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Security;
using System.Text;
using System.Threading.Tasks;
using System.Web.Services.Protocols;
using Wicresoft.EKA.AtriumWebService.CMDB.ClassManagement;

namespace Wicresoft.EKA.AtriumWebService
{
    class Program
    {
        static void Main(string[] args)
        {

            //var str = XMLHelper.GetXML();

            System.Net.ServicePointManager.ServerCertificateValidationCallback = TrustAllCertificatePolicy.CheckValidationResult;
            AtriumWebService.CMDB.ClassManagementWCF.AtriumClasses_PortTypeClient client = new CMDB.ClassManagementWCF.AtriumClasses_PortTypeClient();



            //client.ClientCredentials.UserName.UserName = "admin";
            //client.ClientCredentials.UserName.Password = "Pass01!";
            //client.Open();

    //        UsernameToken TextToken
    //= new UsernameToken(usernameInput.Text,
    //                    passwordInput.Text,
    //                    PasswordOption.SendHashed);
    //        proxy.RequestSoapContext.Security.Tokens.Add(TextToken);
    //        string result;
    //        try
    //        {
    //            result = proxy.PersonalHello();
    //        }
    //        catch (Exception ex)
    //        {
    //            result = ex.Message;
    //        }
    //        MessageBox.Show(result);

            var result = client.ListClasses(new CMDB.ClassManagementWCF.ListClasses()
            {
                //loginInfo = new CMDB.ClassManagement.LoginInfo()
                //{
                //    authentication = "Pass01!",
                //    locale = "",
                //    timeZone = ""
                //},
            });

            //var result = client.ListClasses(new CMDB.ClassManagementWCF.ListClassesRequest());

            //atrium_classes proxy = new atrium_classes();

            ////proxy.Credentials = new NetworkCredential("admin", "Pass01!", "");



            //var x = proxy.ListClasses(new ListClasses()
            //        {

            //        });






            Console.ReadLine();
        }

        public static class TrustAllCertificatePolicy
        {
            public static bool CheckValidationResult(Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
            {
                return true;
            }
        }

        //public class AtriumSoapHeader :SoapHeader
        //{

        //}
    }
}
